<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改小程序用户')" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-member-edit" th:object="${member}">
            <input name="id" th:field="*{id}" type="hidden">
            <div class="form-group">
                <label class="col-sm-3 control-label">用户名称：</label>
                <div class="col-sm-8">
                    <input name="username" th:field="*{username}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">角色：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('member_role')}">
                        <input type="radio" th:id="${'role_' + dict.dictCode}" name="role" th:value="${dict.dictValue}" th:field="*{role}">
                        <label th:for="${'role_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group" id="dealerId" style="display: none">
                <label class="col-sm-3 control-label">所属门店：</label>
                <div class="col-sm-8">
                    <select name="dealerId" class="form-control m-b"  >
                        <option th:each="dict : ${dealerList}" th:text="${dict.name}" th:value="${dict.id}"></option>
                    </select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">手机号：</label>
                <div class="col-sm-8">
                    <input name="mobile" th:field="*{mobile}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">微信号：</label>
                <div class="col-sm-8">
                    <input name="wechat" th:field="*{wechat}" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">性别：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('member_sex')}">
                        <input type="radio" th:id="${'sex_' + dict.dictCode}" name="sex" th:value="${dict.dictValue}" th:field="*{sex}">
                        <label th:for="${'sex_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>

            <div class="form-group">    
                <label class="col-sm-3 control-label">账户状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('member_status')}">
                        <input type="radio" th:id="${'status_' + dict.dictCode}" name="status" th:value="${dict.dictValue}" th:field="*{status}">
                        <label th:for="${'status_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">邀请人: </label>
                <div class="col-sm-8">
                    <select name="introUser" class="form-control m-b">
                        <option value="">无</option>
                        <option th:each="member : ${userList}" th:text="${member.username}+'-'+${member.mobile}+'-'+${member.frameNo}" th:value="${member.id}"  th:field="*{introUser}"></option>
                    </select>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: select2-js" />
    <script type="text/javascript">


        $("input[type=radio][name=role]").on("ifChecked", function () {
            //普通用户
            if ($(this).val() == 0) {
                //展示门店
                $("#dealerId").show();
            } else {
                //隐藏门店
                $("#dealerId").hide();
            }
        })


            var prefix = ctx + "system/member";
        $("#form-member-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-member-edit').serialize());
            }
        }
    </script>
</body>
</html>